minor modifications to expand.c