Fix issues reported by niffiwan