Js improvements

A multitude of JS Improvements. See each commit.