Put keys in a python file, refactored io, refactored code structure