remove prototypes for static functions and fix some potential memory leaks