Improved autoloading code