Did some code refactoring for smaller, more constrained methods