finished algorithms and did some refactoring
Merge pull request #8 from MattFlaig/t9

finished algorithms and did some refactoring