Code used in my research.