removed redundant code, tidying up, etc.