add autoload
some more refactoring