[new stat system] Lua serialization works again. Completely cleaned up the code, too.