Tidied up code, added partials