handle what to show to logged/non-logged users; several optimizations