more debugging and refactoring
more refactoring, bug fixing etc