Added optimization and prediction and they're working okay