Fixed certain bugs