JS API improvements and bugfixes; updated documentation