Tidied up source a bit