Cleaning up dictionary code