Refactoring to use new extension methods. A bunch of cleanup.