Finished sanitizing input.

Need to test to be sure, though.
Fixed bugs from input sanitizing.

I think it's almost ready to be merged, but I have a hunch there's another problem.
Merge branch 'sanitize'