Replace tinsert with optimized tappend

When table.insert is used to append an element to a table-array,
the idiom t[#t+1] = v is more performant, especially with LuaJIT.
added missing local declarations in CommonHelpers.mkdirs
Replace ipairs with 'numeric for' in critical areas

The numeric for is more performant than ipairs, especially in LuaJIT.
See http://lua-users.org/lists/lua-l/2011-05/msg00008.html

This changeset performs this refactoring in areas where it might matter,
such as the common helpers, orm, and router.  Migrations, etc. were skipped.