Fix issue #2552 and PR #2555

cc @simi and @complistic-gaff