Cleaned up code and completed test coverage.