Finished loss functions.