Fix #488 and #489

Two birds with one stone!