dump of GUI code from Matt, since his branch is unmergable