Drawing functions moved to separate file, better exit handling