Started refactorting algorithim code
More refactoring
Finished refactoring of startup and finalized algorithm code blocks.