Prevent v8 optimisations and add boundary checks

Fixes #1