Updated references and fixed Windows compile error
Added Close methods to cleanup open files and handles.

Added some close methods to cleanup open files. More work is needed on
this.