bug fixes in various parts