Optimized and cleaned several methods