Patch 2

Fix some bugs