Improve decoding algorithm for Serialized objects