Electronic, dynamical and superconducting properties of MgB2: doping, surface and pressure effects