added const correctness for lib.c funcs