A lot of tidiying up, making stuff generic