Minor fixes to make this more generic