Added some more comments and reordered sections of the code to make it clearer what someone using it would have to change.