minor fixes, and removal of code redundancies
added foil rule and test