Added null checks. Cleaned up using clauses.