several improvements, also introducing several new bugs