Add remove file support, code refactor.