Work on #544
Work on #543, needs testing