Issue #20: Some cleanup and defect fixes