Cleaned up code according to JSHint