Fix typos and minor bugs