Fixes #2299 and #2324