Added d3.select().moveToFront() and plugged it into component.click() so that clicking on a component brings it to the front if there are overlapping components
Cleaned up startsAt and endsAt to remove repetitive code