added utility template functions to client.h and split out functionality from script.h