Variety of fixes, see commit