adding timing elements and fixing some edge cases