Refactoring, small cleanup before bigger structural changes