Closes #405.
Closes #504. Fix previous commit.