Good developers can only write good code if they can think and plan. Neither of these is ever a sprint objective. The objective of a sprint -- in practice -- is always to bang out the absolutely minimal quality hack required to complete the sprint's objectives.
Nothing distracts good developers to write good code. There is NO excuses. Bad management? Bad mood? Fuck it. Find another job if management can't live with good solutions. Again. No excuses.