Patched some bugs