Added cleanup and utility functions, fixed single, page and index navigation