Fix for cross compatibility
Lots of work