Fix the file mode.
Merge latest april 2013 drop from cvong.

Doesn't build in eclipse.  There is still some refactoring to be done.