Fixed two critical bugs.