put all lib functions in d.c - #186