Refactor resolveDirectory to resolvePath and fixes for completion