Correct resize bug
Cleanup
Mend some memory leaks