Removed all references to apmatrix.
Added C++11 loop construct.
General cleanups.