bug fixes and other improvements