Refactor.
Refactor.
Refactor.
Refactor.
Refactor.
Refactor.
Refactor.
Fix api.
Fix dealing with files.