Cleaned up with some encapsulation.