Formatted code and removed deprecation warnings