Replaced sleep with database polling mechanisms.