Large refactor #2