Reworked relations, replaced tree with lists

Still need to clean it up