Refactoring, fixes to the previous check-in, etc.