Fix bugs reported by kniL