clean up of code, comments added to functions, still more to go!!