Reduce memory 

and fixing bug in custom prefix