Wholesale changes

See the commit history :-)