Lots of stuff, need lots of refactoring still