fix both problems reported by meowmoo and Wally73