Theory of Nanoelectromechanical Systems: From Nanostructures to Molecules