Fixed three bugs in the application template code.