2.0.0 Work In Progress Pull Request

For reference and comparison, help and suggestions welcome

*long way from being finished*

- [x] refactor out environment
- [ ] Get browser building using browserify
- [ ] Tidy up the environment api and document in api.js
- [ ] Move rhino over to browserify and its own environment file
- [ ] Get plugins api better and matching issue