Major algorithm update, added functionality, and bug fixes.