Formatting and added references

Changed formatting of code
Changed value parameters to const references parameters where possible