PR from GCI staging_done branch

Had to do some conflict resolution as well. :|
Although I find "qty" not very conclusive a variable name - should be "count" or something like that.