replaced POSIX with GLib, added logging