three bug fixes