rethought allocation mechanism, removed bad const