make the lua state details thread safe and more useful