Big commit: added the database part, that stores the messages with postgresql. Also, fixed a lot of bugs with encoding.