Fix various bug.