Some obvious bugs fixed