Refactored the front-end and fixed some bugs