Refactor src/ modules and build + packaging process

This code was extracted from the `register-width.js`/`helpers.js` file.