fixed minor bugs, added sleep cycle