Feature/queryoptimisation

Some query optimization and added indexes