Fix allocation of data.

moved inside fromConfig function
Fix error message