Reorder columns
Factor out Lua error handling code