Stat response for files is understood by client, and some code refactoring