More work (incomplete, untested)