Use ensureAuthenticated-function for auth
Url fix for image
Code cleanup
Revert "Code cleanup", fix commit

This reverts commit 7aa3c525d1f6dd386bda9d82a5304e67565acfdc.