Remove unused variables and helper functions