Added comments and resolved some netbeans warnings.