Added some main code and did some debugging and testing.