Minor refactoring, more to come.