more logging and fixing null pointer