more cleaning of unused variables and dead code