Issue refs #1327: fix some bugs