Remove unnecessary midcast code.
Fix state var reference.