Cleaned up the code with some additional comments and fixed the title element.