Code cleanup and refactoring.  Some javadoc and copyright work too