Refactoring sweep.

Also renamed some stuff to more strictly conform to convention.