Tidied, code improvements.