Issue #544 - fixing bugs

Issue #544