Move code out of server for checking access.
Add comments to the methods.