Added support for const.
Fixed type mismatch bugs.