Fixes #12 and also cleans up the code a bit!
Fixes problems with screenshots being saved in backwards order.