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
Fix Win32 build.
Merge pull request #42 from AndrejMitrovic/FixWin32Build

Fix Win32 build.