ENH get rid of local variables in functions