Fixed bug in allocate and allocateTo method.