DEV_WORK Fix authentication holes. Add comments to a few functions