Fix to use one-based subwindow indexing