Fixed null pointers bugs and wrong usage of String.isEmpty.