fixed a serious bug and tracking down another