Renaming detect_motion so I don't feel dirty.  Other minor cleanups.