Code dump including largely code for estimating ALPHA_BF