some const and ref fixes