get it working except for a crash and weirdness at shutdown