fix some issues pointed out in 041033a51af086b48156ff2a9dafb4675b88d99c