Error and shutdown handling working but needs tidying