Cleaned up the code and removed unused sections