Fix type_idx and locks_idx
Fix lua_rawgeti usage, add necessary pops

It was incorrect to supply lua_rawgeti index that was used to be supplied to 
lua_ragwet.