Added a limit to the polling loop.