Minor JSON type checking overhaul

and some general cleaning / simplification