Added a 'tools.c' file for general-use functions