improve input type number detection (fixes #411)