Changed most applayer functions to tak references.