Make "level" a parameter of "serialize" functions instead of an upvalue