Added program timeout

Now if program exceeds a number of steps, it time-outs and throws an
error (prevents infinite loops).