First part of #245