Some minor refactoring here and there.