Managing Energy Markets in Future Smart Grids Using Bilateral Contracts