Cleaned up optical flow code a bit.