Adding comments, fixing a bug and cleanup