added output info about stat errors
moved drawing code to main