bug fixes and various changes