Adding many more comments to explain the algorithm itself.  Some notes on what needs to be addressed, in particular the clamping of patch comparison and splatting.