Index: src/main/java/com/xpn/xwiki/plugin/invitationmanager/api/JoinRequest.java
===================================================================
--- src/main/java/com/xpn/xwiki/plugin/invitationmanager/api/JoinRequest.java	(revision 9750)
+++ src/main/java/com/xpn/xwiki/plugin/invitationmanager/api/JoinRequest.java	(working copy)
@@ -93,12 +93,12 @@
      * @return The status of this request
      * @see JoinRequestStatus
      */
-    String getStatus();
+    int getStatus();
 
     /**
      * @see #getStatus()
      */
-    void setStatus(String status);
+    void setStatus(int status);
 
     /**
      * @return An explanatory text for this request
Index: src/main/java/com/xpn/xwiki/plugin/invitationmanager/api/JoinRequestStatus.java
===================================================================
--- src/main/java/com/xpn/xwiki/plugin/invitationmanager/api/JoinRequestStatus.java	(revision 9750)
+++ src/main/java/com/xpn/xwiki/plugin/invitationmanager/api/JoinRequestStatus.java	(working copy)
@@ -31,30 +31,30 @@
      * The request status is not specified. It can have any of the allowed values. This can be
      * useful when retrieving stored requests.
      */
-    String ANY = "0";
+    int ANY = 0;
 
     /**
      * The request has been created but has not yet been sent
      */
-    String CREATED = "1";
+    int CREATED = 1;
 
     /**
      * The request has been sent but no answer has been received so far
      */
-    String SENT = "2";
+    int SENT = 2;
 
     /**
      * The request has been accepted
      */
-    String ACCEPTED = "3";
+    int ACCEPTED = 3;
 
     /**
      * The request has been refused
      */
-    String REFUSED = "4";
+    int REFUSED = 4;
 
     /**
      * The request has been canceled
      */
-    String CANCELLED = "5";
+    int CANCELLED = 5;
 }
Index: src/main/java/com/xpn/xwiki/plugin/invitationmanager/impl/InvitationManagerImpl.java
===================================================================
--- src/main/java/com/xpn/xwiki/plugin/invitationmanager/impl/InvitationManagerImpl.java	(revision 9750)
+++ src/main/java/com/xpn/xwiki/plugin/invitationmanager/impl/InvitationManagerImpl.java	(working copy)
@@ -55,6 +55,7 @@
  * 
  * @version $Id: $
  */
+@SuppressWarnings("unchecked")
 public class InvitationManagerImpl implements InvitationManager
 {
     public static interface JoinRequestAction
@@ -91,7 +92,7 @@
         try {
             Invitation invitation = getInvitation(space, email, context);
             if (code.equals(invitation.getCode())
-                && invitation.getStatus().equals(JoinRequestStatus.SENT)) {
+                && invitation.getStatus()== JoinRequestStatus.SENT ) {
                 if (!invitation.isOpen()) {
                     invitation.setStatus(JoinRequestStatus.ACCEPTED);
                     invitation.setResponseDate(new Date());
@@ -125,7 +126,7 @@
         try {
             Invitation invitation = getInvitation(space, email, context);
             if (code.equals(invitation.getCode())
-                && invitation.getStatus().equals(JoinRequestStatus.SENT)) {
+                && invitation.getStatus() == JoinRequestStatus.SENT ) {
                 return true;
             } else {
                 return false;
@@ -150,8 +151,8 @@
             if (invitation.isNew())
                 return false;
 
-            String status = invitation.getStatus();
-            if (status.equals(JoinRequestStatus.SENT) || status.equals(JoinRequestStatus.REFUSED)) {
+            int status = invitation.getStatus();
+            if (status == JoinRequestStatus.SENT || status == JoinRequestStatus.REFUSED) {
                 // update the invitation object
                 invitation.setResponseDate(new Date());
                 invitation.setStatus(JoinRequestStatus.ACCEPTED);
@@ -180,7 +181,7 @@
     {
         try {
             Invitation invitation = getInvitation(space, context.getUser(), context);
-            if ((invitation != null) && (invitation.getStatus().equals(JoinRequestStatus.SENT)))
+            if ((invitation != null) && (invitation.getStatus()==JoinRequestStatus.SENT))
                 return true;
             else
                 return false;
@@ -204,8 +205,8 @@
             if (request.isNew())
                 return false;
 
-            String status = request.getStatus();
-            if (status.equals(JoinRequestStatus.SENT) || status.equals(JoinRequestStatus.REFUSED)) {
+            int status = request.getStatus();
+            if (status == JoinRequestStatus.SENT || status == JoinRequestStatus.REFUSED) {
                 // update the membership request object
                 request.setResponseDate(new Date());
                 request.setResponder(context.getUser());
@@ -254,7 +255,7 @@
     {
         try {
             Invitation invitation = getInvitation(space, userNameOrMail, context);
-            if (invitation.getStatus().equals(JoinRequestStatus.SENT)) {
+            if (invitation.getStatus() == JoinRequestStatus.SENT) {
                 invitation.setStatus(JoinRequestStatus.CANCELLED);
                 invitation.saveWithProgrammingRights();
             }
@@ -273,7 +274,7 @@
     {
         try {
             MembershipRequest request = getMembershipRequest(space, context.getUser(), context);
-            if (request.getStatus().equals(JoinRequestStatus.SENT)) {
+            if (request.getStatus() == JoinRequestStatus.SENT) {
                 request.setStatus(JoinRequestStatus.CANCELLED);
                 request.saveWithProgrammingRights();
             }
@@ -291,7 +292,7 @@
     {
         try {
             Invitation prototype = createInvitation(context.getUser(), null, context);
-            prototype.setStatus("" + status);
+            prototype.setStatus(status);
             return getInvitations(prototype, start, count, context);
         } catch (XWikiException e) {
             return Collections.EMPTY_LIST;
@@ -450,8 +451,8 @@
                     + "'");
             }
 
-            String status = prototype.getStatus();
-            if (!status.equals(JoinRequestStatus.ANY)) {
+            int status = prototype.getStatus();
+            if (status != JoinRequestStatus.ANY) {
                 fromClause.append(", StringProperty as status");
                 whereClause.append(" and obj.id=status.id.id and status.id.name='"
                     + InvitationImpl.InvitationFields.STATUS + "' and status.value='" + status
@@ -567,7 +568,7 @@
                 roles.add(role);
                 prototype.setRoles(roles);
             }
-            prototype.setStatus("" + status);
+            prototype.setStatus(status);
             return getInvitations(prototype, start, count, context);
         } catch (XWikiException e) {
             e.printStackTrace();
@@ -641,12 +642,12 @@
      * 
      * @see InvitationManager#getMembershipRequests(int, int, int, XWikiContext)
      */
-    public List getMembershipRequests(int status, int start, int count, XWikiContext context)
+	public List getMembershipRequests(int status, int start, int count, XWikiContext context)
     {
         try {
             MembershipRequest prototype =
                 createMembershipRequest(context.getUser(), null, context);
-            prototype.setStatus("" + status);
+            prototype.setStatus(status);
             return getMembershipRequests(prototype, start, count, context);
         } catch (XWikiException e) {
             e.printStackTrace();
@@ -713,8 +714,8 @@
                     + "' and requester.value='" + requester + "'");
             }
 
-            String status = prototype.getStatus();
-            if (!status.equals(JoinRequestStatus.ANY)) {
+            int status = prototype.getStatus();
+            if (status != JoinRequestStatus.ANY) {
                 fromClause.append(", StringProperty as status");
                 whereClause.append(" and obj.id=status.id.id and status.id.name='"
                     + MembershipRequestImpl.MembershipRequestFields.STATUS
@@ -795,7 +796,7 @@
                 roles.add(role);
                 prototype.setRoles(roles);
             }
-            prototype.setStatus("" + status);
+            prototype.setStatus(status);
             return getMembershipRequests(prototype, start, count, context);
         } catch (XWikiException e) {
             e.printStackTrace();
@@ -927,10 +928,10 @@
 
             // if we get here it means the invitee is not a member of the space
             if (!invitation.isNew()) {
-                String status = invitation.getStatus();
+                int status = invitation.getStatus();
                 // maybe it's an old invitation
-                if (JoinRequestStatus.CREATED.equals(status)
-                    || JoinRequestStatus.SENT.equals(status)) {
+                if (JoinRequestStatus.CREATED == status
+                    || JoinRequestStatus.SENT == status) {
                     // is's a new one
                     addToAlreadyInvited(invitee, context);
                     throw new InvitationManagerException(InvitationManagerException.MODULE_PLUGIN_INVITATIONMANAGER,
@@ -1037,7 +1038,7 @@
         try {
             Invitation invitation = getInvitation(space, email, context);
             if (code.equals(invitation.getCode())
-                && invitation.getStatus().equals(JoinRequestStatus.SENT)) {
+                && invitation.getStatus() == JoinRequestStatus.SENT) {
                 if (!invitation.isOpen()) {
                     invitation.setStatus(JoinRequestStatus.REFUSED);
                     invitation.setResponseDate(new Date());
@@ -1062,7 +1063,7 @@
     {
         try {
             Invitation invitation = getInvitation(space, context.getUser(), context);
-            if (invitation.getStatus().equals(JoinRequestStatus.SENT)) {
+            if (invitation.getStatus() == JoinRequestStatus.SENT) {
                 invitation.setStatus(JoinRequestStatus.REFUSED);
                 invitation.setResponseDate(new Date());
                 invitation.saveWithProgrammingRights();
@@ -1082,7 +1083,7 @@
     {
         try {
             MembershipRequest request = getMembershipRequest(space, userName, context);
-            if (request.getStatus().equals(JoinRequestStatus.SENT)) {
+            if (request.getStatus() == JoinRequestStatus.SENT) {
                 request.setStatus(JoinRequestStatus.REFUSED);
                 request.setResponseDate(new Date());
                 request.setResponder(context.getUser());
@@ -1317,7 +1318,7 @@
      * Creates a custom invitation for the currently logged-in user, from the given one, and then
      * saves it.
      */
-    private void customizeInvitation(Invitation invitation, String status, XWikiContext context)
+    private void customizeInvitation(Invitation invitation, int status, XWikiContext context)
         throws XWikiException
     {
         Invitation customInvitation =
@@ -1464,22 +1465,25 @@
         String strToUsers = join(toUsers, ",");
 
         MailSenderPlugin mailSender = getMailSenderPlugin(context);
+		
+		//gets the demplae coc
         XWikiDocument mailDoc = context.getWiki().getDocument(templateDocFullName, context);
         XWikiDocument translatedMailDoc = mailDoc.getTranslatedDocument(context);
-        mailSender.prepareVelocityContext(fromUser, strToUsers, "", "", vContext, context);
-        vContext.put("xwiki", new XWiki(context.getWiki(), context));
+
+		//puts some generic variables in the velocity rendering context so we can write the template doc almost as a normal document
+		vContext.put("xwiki", new XWiki(context.getWiki(), context));
         vContext.put("context", new com.xpn.xwiki.api.Context(context));
-        String mailSubject =
-            XWikiVelocityRenderer.evaluate(translatedMailDoc.getTitle(), templateDocFullName,
-                vContext, context);
-        String mailContent =
-            XWikiVelocityRenderer.evaluate(translatedMailDoc.getContent(), templateDocFullName,
-                vContext, context);
+		vContext.put("doc", translatedMailDoc);
+        
+		//rendering the template document with the defined velocity context. the subject of the mail is the subject of the template doc and the content of the mail is the content of the doc
+        String mailSubject = XWikiVelocityRenderer.evaluate(translatedMailDoc.getTitle(), templateDocFullName, vContext, context);
+        String mailContent = XWikiVelocityRenderer.evaluate(translatedMailDoc.getContent(), templateDocFullName, vContext, context);
 
+		//creates a new mail
         Mail mail = new Mail(fromUser, strToUsers, null, null, mailSubject, mailContent, null);
 
         try {
-            mailSender.sendMail(mail, context);
+            mailSender.sendMail(mail,context);
         } catch (Exception e) {
             throw new InvitationManagerException(InvitationManagerException.MODULE_PLUGIN_INVITATIONMANAGER,
                 InvitationManagerException.ERROR_INVITATION_SENDING_EMAIL_FAILED,
Index: src/main/java/com/xpn/xwiki/plugin/invitationmanager/impl/JoinRequestImpl.java
===================================================================
--- src/main/java/com/xpn/xwiki/plugin/invitationmanager/impl/JoinRequestImpl.java	(revision 9750)
+++ src/main/java/com/xpn/xwiki/plugin/invitationmanager/impl/JoinRequestImpl.java	(working copy)
@@ -147,10 +147,10 @@
      * 
      * @see JoinRequest#getStatus()
      */
-    public String getStatus()
+    public int getStatus()
     {
-        String status = (String) getValue(JoinRequestFields.STATUS, getObject(getClassName()));
-        return (status == null) ? "0" : status;
+        Integer status = Integer.parseInt((String) getValue(JoinRequestFields.STATUS, getObject(getClassName())));
+        return (int)((status == null) ? 0 : status);
     }
 
     /**
@@ -228,9 +228,9 @@
      * 
      * @see JoinRequest#setStatus(int)
      */
-    public void setStatus(String status)
+    public void setStatus(int status)
     {
-        getDoc().getObject(getClassName()).setStringValue(JoinRequestFields.STATUS, status);
+        getDoc().getObject(getClassName()).setStringValue(JoinRequestFields.STATUS, ""+status);
     }
 
     /**
Index: src/test/java/com/xpn/xwiki/plugin/invitationmanager/impl/JoinRequestTest.java
===================================================================
--- src/test/java/com/xpn/xwiki/plugin/invitationmanager/impl/JoinRequestTest.java	(revision 9750)
+++ src/test/java/com/xpn/xwiki/plugin/invitationmanager/impl/JoinRequestTest.java	(working copy)
@@ -161,7 +161,7 @@
      */
     public void testStatus()
     {
-        String status = JoinRequestStatus.SENT;
+        int status = JoinRequestStatus.SENT;
         joinRequest.setStatus(status);
         assertEquals(status, joinRequest.getStatus());
     }
