fixed logout, commented a bunch, minor formatting