make email images smaller, modify lock/unlock to be atomic