Add null, empty checks throughout