Make type safe by using const keywords when appropriate and improve memory handling by using references when appropriate.