big refactor. Helps the compiler