Removed some unnecessary nil-comparisons. Also some minor style improvements.