Refactored to PEP8.
Fixed issues with whitespace stripping.
Simplified count_neighbors if statement.