error check for size=1 case; additional cleanup