massive refactoring - first commit