Fixed bugs causing failures in constratin generation.