Changes schema design and added messages functions