further encryption refactorings [still in progress]