fixed errors in amavis rewrite