Fixed some scanner bugs and added a small test program.