Research (#491) * add advanced mode for optimal references generator * fix #489 Thanks to Ivan Nikulin for working on it.