cleaned up a few memory issues
Created by: IanS5
After running it with valgrind I found a few memory issues. I think I fixed most of them here. Valgrind reported more, but it looks like somewhere on the backend there was a leak X11 function that was causing it.