file: refactor for optimizations and to do proper NotModifiedErrors