Fixed serialize method.