Add autoloader

Add autoloader function. This needs to be refactored to use SPL.