Reworked deserialization scheme to facilitate scripting.