Updated rules file and fixed some bugs