Fix many bugs and prevent name collisions.