Commenting code and reorganizing to declutter index.js