Fixed some bits of code