Refactoring the timing code.
Some more smaller API tweaks.