fix input spread, fix error and cleanup handling