Refactored a bit. Added RAII lua_State wrapper and set/get global support.