added logging functionality to `def` command; made time.sleep() code better, fixed some bugs