Fixes/Preparation for json deserializer

This is another rip from #260 which fixes a bunch of things. #260 itself needs
to be rebased on this and could then be merged, so please review carefully.
Please describe __exactely__ what problems you did have with the previous solution.