Refactor src/ modules and build + packaging process

Fell free to pull it in locally and switch it to `export function extend(...)` before you merge this.