Fixing loader for libraries
Move logging to a right place