classloading issue fixes and refactor