Fixed null undefined checks so app wont crash