Tidied up logging and added headers to DS code