Slight optimizations added for loading assets, cleaned up some ugly code.