bug fixes and new functions in JS API 

Curry time!