made code tinyer, use log4j and fix NPE