Added initial implementation of the tick callback.
It's an older version of what I wrote, so it might not yet compile. I'll test&debug it soon.