Code quality for this is terrible, we should try to at least get formatting fixed, and add comments to describe logic for all components.