tidying and refactoring
bug fixes - some renaming / refactoring