Merge version 1.2.0 into master

This merges the code of version 1.2.0 into the master branch. This includes a complete reorganisation of the code and new tests.