Code review branch

This is the pull request for a code that needs to be reviewed before it is merged with the master. Please comment on the code in the request. Once all the core code has been reviewed and approved, it can then be merged to master.