Contact binaries at different evolutionary stages