various bug fixes and changes from annie