Moved C calls into es_filesystem, adding cleanup to C