KJ-4 Convert typed expressions into expressions with casts.
Fixed some of the bugs discovered during first round of testing. Just ad-hoc fixing, main remaining issues are not addressed.