Updated spanning tree code, added comments, and made minor fixes