Changed data type of loggedInUserId to Integer as large parts of the code base use Integer userId. This avoids having to cast or convert. Minor other cleanup.

Issue: GCP-8800, GCP-9026