Fixes algorithms and PEP8 bugs