Fix for nasty bug in scanner