Replace cd usage.

Closes #175. Thanks to @remiolsen for finding the bug and
@chapmanb for the fix.