Finished algorithm, front-end, still missing some polish for the front-end