Fix segfaulting on empty directories

Here we go. This fixes #2.