diff --git a/budgetingplugin/0.12/ticketbudgeting/ticketbudgeting.py b/budgetingplugin/0.12/ticketbudgeting/ticketbudgeting.py
index 352c727..48d0e8d 100644
--- a/budgetingplugin/0.12/ticketbudgeting/ticketbudgeting.py
+++ b/budgetingplugin/0.12/ticketbudgeting/ticketbudgeting.py
@@ -1,29 +1,24 @@
+# -*- coding: utf-8 -*-
+
+from pkg_resources import resource_filename
 import re
-import os
 import time
 import locale
-import pkg_resources
 
-from pkg_resources import resource_filename
-from trac.util.translation import domain_functions
-from os import path
-from trac.core import *
-from trac.web.api import ITemplateStreamFilter, IRequestFilter
+from genshi import HTML
 from genshi.filters import Transformer
-from genshi.builder import tag
-from genshi import HTML, XML
-from trac.web.chrome import ITemplateProvider, add_script, add_script_data
-from trac.ticket.api import ITicketManipulator
-from string import upper
-from genshi.filters.transform import StreamBuffer
 
-from trac.db.schema import Table, Column, Index
-from trac.db.api import DatabaseManager
 from trac.config import Option
+from trac.core import Component, implements
+from trac.db.api import DatabaseManager
+from trac.db.schema import Table, Column
+from trac.ticket.api import ITicketManipulator
 from trac.ticket.model import Ticket
-import __init__
-from trac.perm import PermissionSystem
-from compiler.ast import Printnl
+from trac.util.text import exception_to_unicode
+from trac.util.translation import domain_functions
+from trac.web.api import ITemplateStreamFilter, IRequestFilter
+from trac.web.chrome import ITemplateProvider, add_script
+
 
 _, tag_, N_, add_domain = domain_functions('ticketbudgeting', '_', 'tag_', 'N_', 'add_domain')
 
@@ -75,7 +70,7 @@ class Budget:
                     else:
                         try:
                             self._budget_dict[fld] = locale.atof(value)
-                        except Exception, ex:
+                        except Exception:
 #                            print "exception (locale.atof): %s" % ex
                             self._budget_dict[fld] = float(value)
                 except Exception, e:
@@ -92,7 +87,7 @@ class Budget:
             return
 
 #        print "[do_action] ticket_id: %s, position: %s" % (ticket_id, position)
-        db = env.get_read_db()
+        db = env.get_db_cnx()
         cursor = db.cursor()
 
         flds = None
@@ -208,20 +203,19 @@ class TicketBudgetingView(Component):
     u"""SELECT t.id, t.summary, t.milestone AS __group__, '../milestone/' || t.milestone AS __grouplink__,
     t.owner, t.reporter, t.status, t.type, t.priority, t.component,
     count(b.ticket) AS Anz, sum(b.cost) AS Aufwand, sum(b.estimation) AS Schaetzung,
-    floor(avg(b.status)) || '%' AS "Status",
-    (CASE t.status
-      WHEN 'closed' THEN 'color: #777; background: #ddd; border-color: #ccc;'
-      ELSE
-        (CASE sum(b.cost) > sum(b.estimation) WHEN true THEN 'font-weight: bold; background: orange;' END)
-    END) AS __style__
+    %(status)s || '%%' AS "Status",
+    (CASE
+      WHEN t.status='closed' THEN 'color: #777; background: #ddd; border-color: #ccc;'
+      WHEN sum(b.cost) > sum(b.estimation) THEN 'font-weight: bold; background: orange;'
+     END) AS __style__
     from ticket t
     left join budgeting b ON b.ticket = t.id
     where t.milestone like
     (CASE $MILESTONE
-              WHEN '''' THEN ''%''
+              WHEN '' THEN '%%'
               ELSE $MILESTONE END) and
     (t.component like (CASE $COMPONENT
-              WHEN '' THEN '%'
+              WHEN '' THEN '%%'
               ELSE $COMPONENT END) or t.component is null) and
     (t.owner like (CASE $OWNER
               WHEN '' THEN $USER
@@ -276,8 +270,12 @@ class TicketBudgetingView(Component):
 #    group by t.id, t.type, t.priority, t.summary, t.owner, t.reporter, t.component, t.milestone""")
 
     def __init__(self):
-        locale_dir = pkg_resources.resource_filename(__name__, 'locale')
-        add_domain(self.env.path, locale_dir)
+        try:
+            locale_dir = resource_filename(__name__, 'locale')
+        except KeyError:
+            pass
+        else:
+            add_domain(self.env.path, locale_dir)
 
     def filter_stream(self, req, method, filename, stream, data):
         """ overloaded from ITemplateStreamFilter """
@@ -687,7 +685,7 @@ class TicketBudgetingView(Component):
         if not tkt or not tkt.id:
             return
         cur_time = self._get_current_time()
-        db = self.env.get_read_db()
+        db = self.env.get_db_cnx()
 
         try:
             for pos, budget in self._budgets.iteritems():
@@ -700,7 +698,6 @@ class TicketBudgetingView(Component):
                     old_value = "%s, %s: %s" % (budget.get_value(1), budget.get_value(2), budget.get_value(6))
                 elif action == 'update':
                     continue
-
                 sql = "INSERT INTO ticket_change(ticket, time, author, field, oldvalue, newvalue)" \
                                " VALUES(%s, %s, '%s', 'budgeting.%s', '%s', '%s')" % (tkt.id, cur_time, change_user, pos, old_value, new_value)
                 db.cursor().execute(sql)
@@ -738,50 +735,44 @@ class TicketBudgetingView(Component):
         Constructor, see trac/postgres_backend.py:95 (method init_db)
         '''
         conn, dummyArgs = DatabaseManager(self.env).get_connector()
-        db = self.env.get_read_db()
+        db = self.env.get_db_cnx()
         cursor = db.cursor()
         try:
             for stmt in conn.to_sql(BUDGETING_TABLE):
-                if db.schema:
-                    stmt = re.sub(r'CREATE TABLE ', 'CREATE TABLE "'
-                                  + db.schema + '".', stmt)
                 stmt = re.sub(r'(?i)bigint', 'NUMERIC(10,2)', stmt)
-                stmt += ";"
                 self.log.info("[INIT table] executing sql: %s" % stmt)
                 cursor.execute(stmt)
-                self.log.info("[INIT table] successfully created table %s" % BUDGETING_TABLE.name)
             db.commit()
+            self.log.info("[INIT table] successfully created table %s",
+                          BUDGETING_TABLE.name)
         except Exception, e:
-            self.log.error("[INIT table] Error executing SQL Statement \n %s" % e)
+            self.log.error("[INIT table] Error executing SQL Statement%s",
+                           exception_to_unicode(e, traceback=True))
             db.rollback();
+            raise
         finally:
             db.close()
         self.create_reports()
 
     def create_reports(self):
 #        print "[INIT report] create_reports: %s" % self.BUDGET_REPORTS
-        for report in self.BUDGET_REPORTS:
-            try:
-                db = self.env.get_read_db()
-                myCursor = db.cursor()
-                self.log.info("having myCursor")
-                descr = _(report[2])
-                self.log.info("descr: %s" % descr)
-                descr = re.sub(r"'", "''", descr)
-                self.log.info("report[3]: %s" % report[3])
-                self.log.info(" VALUES: %s, '%s', '%s'" % (report[0], _(report[1]), report[3]))
-                sql = "INSERT INTO report (id, author, title, query, description) "
-                sql += " VALUES(%s, null, '%s', '%s', '%s');" % (report[0], _(report[1]), report[3], descr)
-                self.log.info("[INIT reports] executing sql: %s" % sql)
-                myCursor.execute(sql)
-                db.commit()
-                self.log.info("[INIT reports] successfully created report with id %s" % report[0])
-            except Exception, e:
-                self.log.error("[INIT reports] Error executing SQL Statement \n %s" % e)
-                db.rollback();
-                raise e
-            finally:
-                db.close()
+        try:
+            db = self.env.get_db_cnx()
+            myCursor = db.cursor()
+            for report in self.BUDGET_REPORTS:
+                sql = "INSERT INTO report (id, author, title, query, description) VALUES (%s, NULL, %s, %s, %s)"
+                query = report[3] % {'status': db.cast('AVG(b.status)', 'int')}
+                myCursor.execute(sql, (report[0], _(report[1]), query, _(report[2])))
+                self.log.info("[INIT reports] successfully created report with id %s",
+                              report[0])
+            db.commit()
+        except Exception, e:
+            self.log.error("[INIT reports] Error executing SQL Statement%s",
+                           exception_to_unicode(e, traceback=True))
+            db.rollback();
+            raise
+        finally:
+            db.close()
 
 
     def get_col_list(self, ignore_cols=None):
