Initial code added. It probably doesn't work on lua 5.1 (unless it's luajit2).