Added comments and made stuff generally neater. Still need to add comments about when events.