Replaced all calls to malloc, calloc and free by their respective glib versions