Did some cleanup and documentation on JavaScript code