bug fixes in various places