merge Gordos working branch

These commits both close #7 and fix #6. Also, more comments in the code so it's easier to follow.