Compatibility fixes

Several small compatibility fixes and some small JS fixes.