Tiny fixes and refactorings to the previous commit