Don't leak filename_fs on errors.
Removed some unnecessary null-checks for calls to g_free and g_strfreev
Minor tidying up
Fixed leak of filename string.
Removed some commented-out code.
Removed some unnecessary casts.