On the consumer side of the electrical grid, there are some demands with some kind of "flexibility" in nature. Wisely exploiting these flexibilities could result in better utilization of the available resources.Inspired by the existence of electric appliances with flexibility on their charging rate, we study the problem of optimally serving a set of "Malleable Rectangular-Shape" energy requirements in a finite time interval. That is each demand must be supplied continuously with a constant intensity and duration bounded by left-and right-malleability constraints. At each moment of time, the total power consumption of the grid is the sum of all the consumption rates of the demands being supplied at that moment. First, we assume that the malleability constraints are the same for all demands. Then, we identify the lower bound on the optimal value of the power peak. We extend our study by considering stochastic malleability constraints, where each demand has its own constraint pair. In this case, we also include a convex cost of power consumption in our treatment. In each case, we propose an on-line scheduling algorithm, which is asymptotically optimal with respect to the given cost criteria.As another type of flexible demands, we address the problem of controlling a charging station of Plug-in Hybrid Electric Vehicles (PHEVs), assuming they can tolerate rejection of their energy request. We introduce a model for a charging station, in which PHEVs are charged either directly from the electrical grid or from a local storage unit deployed for each class of customers. The control actions to be determined by the charging station operator are as follows: the probability of blocking new arrivals, the rate of charging each local storage unit, the proportion of cars being served by each local storage unit and eventually the proportion of the available power from the grid to be assigned to each class of customers. We will show how to find a control policy minimizing the utilization cost of the charging station.