Fixing Bugs

Fixing some bugs, improving rules