Minor changes to make threading easier later