Cleaned up code. added a test code finish.