Fixed issue 1405 and 867 (duplicate)

Signed-off-by: Jonas Groeger <jonas.groeger@googlemail.com>