Minor fixes for JSON serialization (renamed $ to $type, improved exception handling, disabled ref loop check, added constant)