Change transaction API to RAII style