Use glib's time function instead of gettimeofday. Should be more portable.