Reorganized index.js into modules