Thanks johnwasser and pcbbc, I was not aware of the variables not being preserved over function calls. That would explain why my "StartTm" is "lost/garbage". I expected a user function to behave like an "instance", where each instance would remember its own variables.
Declaring variables as "static" will only solve my problem for a single instance (but it does work, thank you). A second instance will thus overwrite the first instance's variables.
Back to the drawing board for me...