General code used for research.