Magnetization switching and microwave oscillations in nanomagnets driven by spin-polarized currents