Added a lot of code, porting @jorgedelcasar javascript API