Moved text area rendering to separate function, fixed memory leaks