Refactored code and fixed asset loading.