Completely refactored into a new class.