Cleaned up and removed unused code