bug 511 fixed. Need testing to check it.