fixed bugs in applayer.