Various fixes, including new procedure to do candidate generation using a window