Re-factored for continuous integration support.