bug fixes to code