Attempted to clean up the Scanner code.

Also fixed some build errors. It kinda works again now.