made map rebinning more robust. reorganised /gen_library?