Overlay networks form the core part of peer-to-peer (P2P) applications such as application-level multicast, content distribution and media streaming. To ease development, middleware solutions and toolkit libraries have been proposed in the past to help with the implementation of overlay networks. Existing solutions, however, are either too generic by only providing low-level communication abstractions, requiring developers to implement algorithms for overlay networks from scratch, or too restrictive by only supporting a particular overlay topology with fixed properties. In this paper, we argue that it is possible to find a middle ground between these two extremes.We describe Hyphen, a middleware for overlay construction and maintenance that supports a range of overlay topologies with custom properties, and show how it can replace topology construction for a variety of application-level multicast systems. Unlike previous efforts, Hyphen can construct and maintain a range of overlay topologies such as trees and forests with specific optimisation goals such as low latency or high bandwidth. By using a gossip-based mechanism to define topologies implicitly, Hyphen can scale to many peers and achieve low construction overhead. Our experimental evaluation with Bullet and Splitstream, two P2P streaming systems, shows that Hyphen can construct a bandwidth-optimised tree for Bullet that achieves a higher streaming rate than the original Bullet implementation, and that it can construct a more reliable forest for Splitstream by taking individual peer reliability into account.