Fixed bug where minimizing window would cause a segfault.