Partially refactored all javascript into self-contained app object. Feels much nicer.