Add casts and group by to RMI/RSA functions. Add missing labels. Typo.