Removed unused functions, simplified code