huge refactor, mostly coding standards