Fix returned value when the previously store value was null.
Bonus: code cleanup.