Fix problem with serializing classes where inheritance is involved.