small refactor to fix the library levels problem. I don't think this will fix the clang build, still working on that mystery