use of source() within functions
A number of the functions call source() within the function body, for example lines 3 and 4 of find_gap_func.R. This forces the code within those external files to be reloaded each time the function is called. In turn this triggers the just in time compiler (JIT) each time the function is called, leading to poor performance.
Solution - move all source() statements out of the function bodies,