Huge refactoring ... I know it's bad