moved procedural functions into lib dir