Some work on making program more flexible; more to follow