Reworked autoloader function to prevent potential issues.