Refactor configure

Includes commits from #27