Implements #358 and #359