Gem cast, more misc fixes