JavaScript fixes and documentation