code improvements for 5476daa - rryan suggestion
remove block handled in 403dbfc - rryan suggestion
Revert "Structurally dead code - remove unused/unreached 'return'"

@rryan: This is library code (imported from elsewhere) so I'd prefer not modify it so minimize diffs if we re-sync later.

This reverts commit a204bf8c0db422961e76dcc77aba0d0e9c3d416b.