Finishes up part 1 for now. Could be improved, but I messed up on the structure early on and didn't have an opportunity to fix.