Lifted out of the monolithic Akela library. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>