uuuh, mostly still broken
more refactoring