算法的总体思路

General algorithm and structure of code. TODO: fill in real stuff