Add all code from original APM. 2013\04\26