factored out drawing/io code into separate modules