First working version on the command line. Good stopping point.