Fixed critical bugs