fixed some bugs detected by test/application.py.