Bugfixes brought from develop-bill.