reorganized a lot of free functions and includes, to follow standard practice... also started jar_main