some bug fixes and minor changes