Cleaned up front-end javascript