Improve autoloading code