added type system, updated many relations, made database faster, rewrote stats and invoices