mail/bp: fix a bunch of bugs