Add NSDocument.cs to the build and fix compiler errors.