Drop some nesting from the flow
Break out more functions, reduce global deps