Repaced flagsremove Lua function with new removeflags.