many bug fixes, 1st imll of code by rule