LOTS of javascript fixes