Getting a little waterfall-of-death-y in here -- maybe pull these out into named functions? Or at least give them all names so if they crash, we can see where?