Added implementation for casts and constants, and a variety of other min...

...or bug fixes and test additions.