First stab at windowing. Runs, but I think I'm messing up the indexes.