Added counting for switches

Changed some variables, comments around