Tidied up docs, moved some functions