Standardized code and removed a few unnecessary checks.