small code cleanup, shifted some functions to glib