each to each_value; remove unused vars

1. each to each_value
2. remove unused vars