Add comments and organise the API