#279 Removed dead code and added initialised check to avoid NPEs