Updated common functions.
Fixed const qualifier issues.
Improved const-correctness.
Minor updates in debug printing.