Fixed bug in marginalization