Moved some functions to funcs.inc