Frame logic. Sliding window implementation.