Checkboxes Defaulting to Selected When Not Desired
I think you have to set the value in each checkbox, so probably this would be it :

foreach ($license_result as $license) {
  $licenses[$license-&gt;code] = htmlspecialchars($license-&gt;name);
  $licensevalues[$license-&gt;code] = 0;
}
$selected_licenses = array();
return array(
  'selected_licenses' =&gt; array(
    '#type' =&gt; 'checkboxes',
    '#title' =&gt; t('Licenses to Display'),
    '#description' =&gt; t('Select which licenses the student should be able to select'),
    '#options' =&gt; $licenses,
    '#default_value' =&gt; $licensevalues,
  ),
);