minor changes, added comments, fixed some tests