Automatic reallocation

fix hash

fix allocation bug