Whitespace cleanup + basic refractoring.