Fixed null pointers when placing flag