Fixed two bugs mentioned by @AquarHEAD.