Full refactor