Code cleanup and enhancements of Words Document