Added mechanism for const functions. Needs more testing.