Moved variables to processor.

Also wrapped everything in a function to prevent global pollution and
added processor tests. And some other stuff.