added auth checking for all resources
fixed unused global variables
added comments