Added memo decorator to replace kludgy cache