Code unfucked a bit, some of PEP8 aplied.