Fixed bug introduced in #676

This fixes the bug introduced in #676. This also addresses #681.