Fixed a null-referenced bug
Fixed small bugs founded with findbugs