Refactored/fixed lots of bugs to enable usage of

esprima inside the vm