Bug789 v1.4 part2

Here's the part2 of bug #789. This is the most controversial part and the rebase was extremely painful so I beg you to be kind with me ;)