A lil code cleanup and updates to the latest tern - minus a change that introduced a regression