Nanoscale investigation and control of the interfacial properties of organic solar cells and organic thin-film transistors