Cleaned up the code and fixed a problem with the guild side value being unknown.