Fix const related bugs in optional references