Improvements to code and some more testing.