A consistent framework for valuation under collateralization, credit risk and funding costs