Check for NPE and also optimze HashSet allocation
Javadocs cleanup / added