Minor bug fixes and flushed out the algorithm helper functions.