Cleaned up many duplicate functions