added media endpoint project and tidied up code a little