Minor edits and refactoring. Test updates.