Issues #2367587 and #2329721 by IshaDakota: Fixed mechanism to load JS properly and fixed a Fatal error caused by drupal_add_html_head().