First rough-in of the pseudocode with supporting routines.