Sapporo2: a versatile direct N-body library