Add some commments and organise the file a bit