many bug fixes after testing on 10 structures