big refactoring, starting to get testing going