Allocation code partially implemented. Various fixes.