Revert "Refactor the code in a fairly trivial way."

This reverts commit 8f790e9a10c95dc32415bf84f8b5dffa4791900a.
Adds profile support to javascript driver.