Spanclass fixes

This should fix the issues described in #4665

Fixes #4665