bug fixes through #45