Make doc a required argument, add comments, cleanup example