made database,pages global, fixed many 1 page bugs