Fixed ICE and did minor cleanup