Possibly more complete solution

This is a very old PR that should have been opened and resolved 2 years ago :(