Partial code refactoring.