Fix some bugs; bp: fix encryption bug