Updates to code, clean and add sanitize function.