Adding/editing invoices functionality, many general fixes