declare local variables static and remove g_prefix. this removes a clash with another global variable...