Removed unused code.
Added global variable for max candidates.