Fix problems reported by @philix