Added type checking on reader.tokentype