Minor code tweaks. Tests reliably passing.