Compile error & nullpointer fix