Minor cleanup of compact prototype

Fix warnings, fix memory leaks, externalize stats code, fix 64-bit
compatibility issues (modulo _memory size - tbd).