Simplified code, added more comments, fixed sleep and modified the readme.