Fixed a few UI things and refactored some JS