Tidied up code formatting and docs