bug fixes and minor changes