Added functionality for counting optional arguments.