Make bad code that I wrote better

I know this is too many pull requests but at least I'm merging them myself