Rest of the refactoring. Things works now, version number and readme needs updating.