Merged SirCmpwn's serialization code - PR #2