Fixing various critical bugs.