fixing bugs 3513, 4278, 4243 and 4287