We should try to keep the xml rather lua free in the future. Consider moving this to be a function inside CodeField lua file.