additional fixes, incorporating scott's changes