Refactor all the things and add command line scripts.