Add some cleanup code

Did some leak checking with valgrind and removed some obsolete code.
Fix errors with destoyed windows

Xlib errors aborted the program. I switched to using XCB for DAMAGE
extension. And then ignored the error messages for DAMAGE extension,
which are related to destroyed windows.