Thesis submission version. Improved modularity, added code for 2013 competition