Improved resize handler, less memory leak