Cleanup index and factored out js