Fixed structure detection bug. Issue #141