I have been faced with this kind of if problem before and somehow fixed it -reset pin was left hanging.
My Atmega1284 resets when relays release/switch off AC motor. Sometimes the code hungs/stops or lcd throws unintended characters. Turning on the motor shows no problem.
The motor appears to be the only problem; removing it from the design restores everthing to norm.
I have the 0.1uf on the power rail of mcu, reset pin is pulled up, Brownout is default,optoisalators actuate the relays, common ground but relays operate on 12v.
Will Rc cross the motor help, I'm not sure about the values though. Motor is 14W 240VAC.