Merge with cern - DO NOT MERGE

A cleaner version of #20 - will be broken up further