Added error checking and commented the two scary methods pretty thoroughly.