Added header checks
Overwrite internal memory buffers after usage
Removed debug output and streamlined return codes
Made memory overwrite a separate feature