We develop a consistent, arbitrage-free framework for valuing derivative trades with collateral, counterparty credit risk, and funding costs. Credit, debit, liquidity, and funding valuation adjustments (CVA, DVA, LVA, and FVA) are simply introduced as modifications to the payout cash flows of the trade position. The framework is flexible enough to accommodate actual trading complexities such as asymmetric collateral and funding rates, replacement close-out, and re-hypothecation of posted collateral-all aspects which are often neglected. The generalized valuation equation takes the form of a forward-backward SDE or semi-linear PDE. Nevertheless, it may be recast as a set of iterative equations which can be efficiently solved by our proposed least-squares Monte Carlo algorithm. We implement numerically the case of an equity option and show how its valuation changes when including the above effects. In the paper we also discuss the financial impact of the proposed valuation framework and of nonlinearity more generally. This is fourfold: First, the valuation equation is only based on observable market rates, leaving the value of a derivatives transaction invariant to any theoretical risk-free rate. Secondly, the presence of funding costs makes the valuation problem a highly recursive and nonlinear one. Thus, credit and funding risks are non-separable in general, and despite common practice in banks, CVA, DVA, and FVA cannot be treated as purely additive adjustments without running the risk of double counting. To quantify the valuation error that can be attributed to double counting, we introduce a "nonlinearity valuation adjustment" (NVA) and show that its magnitude can be significant under asymmetric funding rates and replacement close-out at default. Thirdly, as trading parties cannot observe each others' liquidity policies nor their respective funding costs, the bilateral nature of a derivative price breaks down. The value of a trade to a counterparty will not be just the opposite of the value seen by the bank. Finally, valuation becomes aggregation-dependent and portfolio values cannot simply be added up. This has operational consequences for banks, calling for a holistic, consistent approach across trading desks and asset classes.