Refactor buildConfig to handle non-existent and empty directories

Fixes #93