way more phi/branching stuff; almost complete