Fixed sliding-window-smooth script

There were some bugs. I fixed them. I think I accidentally commited it while
working on something else.