Tidying up, commenting, some bug fixes!