bug fixes and changes from Rick Adams