Minor fixes.
More refactoring/simplification.