modify allocation methods for heapsafe mode