Merged mvidner's changes