relay: reorganize base classes of library