Solves #24 and more.