Added some comments, BSD license, and updated some variable names.