Fixed key_names and added debugging statements