remove some unused functions and function arguments, change order of some function arguments and tuples