added javadoc, some null attributes checking