Cleaned up and reworked network layout logic