Changed factorize to return error. The error value was being lost and could not be recalculated. Global problem?