fixes for authentication checks

#6 
#5 
@lawinslow take a look and merge or comment on changes?