Moved most lua related code to luafunc.c