finished basic refactoring; extensive testing and further refactored structure clarification will follow