Fix potential error if changeset ID doesn't match up to user record.
Abstracted data selection creation to a factory object in preparation for introducing prepared statements.
Merge pull request #10 from tomhughes/master

A few more fixes