Merged Dan's refactorings.