Fixed and really neatened up. Ready for merge with Master.