dev-466: simplified chain filtering
dev-467: limit the max #chains to extend
dev-468: fixed a segfault caused by NULL