Tidied up the api a little.