Fixing bugs 1212 and 1213