Merge common changes

Fix changes from encrypt and directory handling.