Corrected bugs introduced by previous commit