bug fixes; all tests passing