Did some codes-keeping, added comments, fixed bugs on directing page to index page if anyone is not logged in.