Merged new version

A significant change to the code. I have tagged old version as v1.0
I had to create this temporary branch to manually merge the changes in and resolve conflicts.