Javascript fixes and layout improvements