Added cost functions.