Move general functions out of typedefs.h