We report a self-adapting version of the Wang-Landau algorithm that is ideally suited for application to systems with a complicated structure of the density of states. Applications include determination of two-dimensional densities of states and high-precision numerical integration of sharply peaked functions on multidimensional integration domains.