implemented sleep but freezes

Sleep seems to work, but freezes when waking up and trying to
reestablish wifi connection.