Do some type checking in ask(), issue 2322 

and fix for issue 3526