Fixed a two small logical errors