fix #822 & related mess