Added flag based deserialization. Fixes #1.