p.type check fixed, added exception handling for json export
fixed confusion while merging issue #14 (which created #15) - both fixed now, forever