Add metadata to received messages

Still need to review and test this. Testsuite passes though.