Need to start tidying this up some more.