added more commenting to views and tidied code