add some cairo graphics handling back in, tidy up command processing, plug memory leaks
add valgrind