Made the mandrill code more modular