move most code to autoload