some bug fixes and changes