PEP8 cleanup and removed magic numbers