simplify dealing with system classloader and clean up

Simplify code dealing with using system class loader and general clean up.