Fixed some hard-to-see bugs