Fixed several simple bugs discovered in initial testing.