fixing some delete issues and adding reference column