Finish the recognizing part of the routine

Lots of TODOs....