add affect count, various fixes