Major Bugfix Messy Version

I'll try to submit a cleaned up version of this by tomorrow... I'm
pretty sure about a third of this is unneeded, but I was trying a
variety of methods to fix the double refresh issue, as well as adding in
support for reading from a file.