bug-1023 fixed some flaws detected by software review