start of massive refactoring