added changes to correctly deal with various stride patterns.