Fixed bugs with reading/writing scalar types and reading complex types.