Minimize stat calls. Also a few refactorings.
Minded feedback. Also added some more yapping in which().
Merge pull request #41 from andralex/master

Minimize stat calls