Refactor - separate file mode stuff out to core.go.

Minor bugfix in Cp implementation encountered during aforementioned
refactoring