indented some long lines, calcAdjacencies still ugly as hell but it works