added error threshold to be configurable - also fixed some permission bugs