Bart's setup branch, rebased

Fixes #591. Rebase of #774.