Major code cleanup

Major code cleanup to align with pep8 conventions. Switched cache loading to with statements, safer and better. No more open file descriptors floating around.

Obviously test it locally with your debug subreddit first, as I haven't been able to thoroughly test this for obvious reasons

95% of this is just syntax and pep8 convention cleanup

5% is the with statements for loading DB cache files. You mentioned in a comment in your code that there was probably a better way to do it, so figured it'd be ok to have a crack at it.