This took waaaaay too long. Added new algorithms and fixed bugs.