more STATs and better error handling