Added serialisation for database storage