Applying commit 1f91cdbefc2d45fb5510a3a47d926725f288eb87
Plus one bug fix!