Cleaning up the mode parser, this has some poor code from acora in it back in like 2008. Using lodash loops where applicable
Removing use of for-in loops because this prevents V8 from doing optimisations on the running functions. Closes #57