update for beem: automatic chain detection and several improvements...