Part of work for #347
Part of work for #347