fixed numerical instability in computation of sigmoid gradient
add support for different priors - still in compatibility mode