Improved timing, still needs testing.