Refactored areas that needed improvements