Fixed bug in custom_getdents/custom_getdents64 and partial code refactoring