Modified addnodetoring to handle some corner cases. Not 100% fixed.