move stack frame and force-early-return code into separate files.
lj_get_frame_count() now requires a thread parameter
fix to only release pointer if actually allocated