added const/const-pass-by-reference to everything,intuduced some bugs with detection.