Rework some python code, split shared code into separate files
More python work, add fake dicts for easy testing