layout fixes & sql queries optimisation