Extensive refactoring. Moving away from statics. Almost compile again.