Code ported to new version of lua-lovetoys