@VirtualVirgin
You shouldn't declare a function within a paint routine or mouse callback. I'm pretty sure that will reallocate memory for every redraw of the screen or mouse movement.
Functions should be declared in on init, and 99% of the time they should be inline functions.
For paint routines and the like for your factory functions, I would declare them outside of the factory function - unless they're really short. This is more of a code cleanliness thing though than a performance issue.
local t = Engine.createTimerObject();
t.setTimerCallback(function[panel, t, rangeMinMaxArray]
Why don't you use the panel's built in timer instead of using a separate timer object?