Added implementation for casts and constants, and a variety of other minor bug fixes and test additions.