Fixed deprecation warnings and improve code legibility