Added an advanced refcounting example, fixed this_executable detection on POSIX and minor improvements to the code