Clean up memory code, use built-in BYTE type instead of making our own.