glthread: check the size of all variable params and clean up the code