Add logout functionality and fix headers