Adding setup routines and tidying up.