better debugging when serialize() fails