This port of recent changes to 2d should have been committed earlier