Complete Overhaul

The cookie handling didn't function correctly at all before. Although
the code works, it still isn't suitable, but I'm making it public since
I don't have the time to work on it right now.