Fixed the problems reported by @xabbuh