Fixes to js asynchronous calls. Made synchronous.