Make directory logic a bit more OS-agnostic