No longer uses globals, or deprecated module function

Hi, 
Just made a quick change to this awesome piece of code, so that it does not relies on Lua's module, which is deprecated in Lua 5.2.
Instead of defining a global module, it just returns a local state manachine constructor. Safer, IMHO.

Regards,
Roland.