Sleep properly rather than spinning CPU; fixes #454.