added support for maximum run count. Better error reporting and handling. Renamed