Added timing and background sleep functionality