Some javascript code cleanups