Patch some bugs