Lots of new code, untested