fix small bugs that are found in issue #579

fix #579