Add a sleep.
Cleanup codes, fix minor issues.