Density functional formalism at finite temperatures with some applications