Significant reorg to improve readability/modularity