Extracted control loop.
Cleaned up cmakelists.