  We study five dimensional AGT correspondence by means of the q-deformed
beta-ensemble technique. We provide a special basis of states in the q-deformed
CFT Hilbert space consisting of generalized Macdonald polynomials, derive the
loop equations for the beta-ensemble and obtain the factorization formulas for
the corresponding matrix elements. We prove the spectral duality for Nekrasov
functions and discuss its meaning for conformal blocks. We also clarify the
relation between topological strings and q-Liouville vertex operators.
