Move Lua-based WML macro optimization bits to separate files