fixed isAdjacent and some other minor changes + comments.