add v2 support and cleanup