I think this is a first step in order to improve the code of the main loop,
because it will make the loop more understable. I think in the final
implementation of the main loop we shouldn't need this separation, because
it should be enough simple and clear that spliting it in functions
shouldn't be necessary.

I am going to apply the patch of FRIGN about monotonic clock before
your patch, , that conflict with your changes. If you can rebase
this patch with that patch could be great (I hope I could push the
patch of FRIGN soon). And, please be careful with the style ;). St
code doesn't use underscore for names (I am not an maniatic about it,
but there is a style police that catch all the fails!).