1) added a sanity check to help diagnose problems with class loading
2) performed some code cleanup