Fixed some bugs raised by Muhammad