Gsoc 2014 message carbons

Please review the message carbons implementation.
@shambhuprasad58 : would you consider extracting the checking logic out of this function and writing some tests for it? The `case` stairway is something we like to avoid when possible ;)