Added smarter timer and recursion depth