Fixed some allocation issues and rendering destruction