Error fixes - see individual commits