Fix NullPointer & warnings