Save function

also behind-the-scenes changes in preparation for adding line and fill
tools