Importing fixes from fosp.js