Minor reordering, prep for Flask port