cleanup and added getBaseMemPtr