reformatted source
added scripting support for rules