Massive cleanup on loading.

Fixed several autoloading bugs.