bug fixes to new code