Change database to PostgreeSQL, some fixes