Tidied up internals