Partial fix of feature4.
Fixed bug #2.
final fix of feature #4.
Merge branch 'feature4-fix'