Bug fixes and test program