if (me==NULL) {return;} //trying to get rid of invalid argument bug.
This would not get rid of invalid arguments. If would only detect that me were NULL, but not a removed entity or an entity pointer containing garbage. Only the error message really indicates that me is not a valid entity. I'd suspect a removed entity here.
When you post code, please use the code tag. Otherwise it's hard to read.