Refactor auth + minor improvements