Fixed some logic/typos.