Cleaned up JS and PHP