initial reorganization into lib dir, completely untested! :)