Correlations in nuclei. Self-consistent treatment and the BAGEL approach