Some refactoring here and there.