Support public and admin modes
Code clean-up and comments