Refactored some of the front-end code