general clean up, removing duplication where possible and making things more consistent