Add transaction support and improved adding indexes