Close NERDTree if it's the only thing open.

Also some minor reorganization.