Fixed some obvious bugs