Reorganize imports
Simplify code
Factor out Cross-Origin Resource Sharing stuff